package com.datawin.taotaocheche.util;

import android.os.Handler;
import android.widget.Toast;

import com.datawin.taotaocheche.comm.MyApplication;


/**
 * Created by admin on 2017/8/4.
 *
 * toast 提示
 */

public class ToastUtils {
    private static Toast toast;

	public static void shortToast(String msg){
        if(toast==null){
            toast= Toast.makeText(MyApplication.context, msg!=null?msg:"未知", Toast.LENGTH_SHORT);
        }else{
            toast.setText(msg);
            toast.setDuration(Toast.LENGTH_SHORT);
        }
        toast.show();
	}
	
	public static void longToast(String msg){
        if(toast==null){
            toast= Toast.makeText(MyApplication.context, msg!=null?msg:"未知", Toast.LENGTH_LONG);
        }else{
            toast.setText(msg);
            toast.setDuration(Toast.LENGTH_LONG);
        }
		toast.show();
	}
	
	public static void customToast(String msg, long l) {
        if(toast==null){
            toast= Toast.makeText(MyApplication.context, msg!=null?msg:"未知", Toast.LENGTH_SHORT);
        }else{
            toast.setText(msg);
        }
        toast.show();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                toast.cancel();
            }
        },l);
    }
}
